import O1HD from "../../../engines/gameEngine";
import level_peopleArchery_openBoxDialog from "../page/level_peopleArchery_openBoxPage";

const {ccclass, property} = cc._decorator;

@ccclass
export default class level_peopleArchery_boxDialogItem extends cc.Component {

    @property({type:cc.Node,tooltip:"显示节点"})
    iconNode:cc.Node = null;

    @property({type:cc.Node,tooltip:"视频节点"})
    videoNode:cc.Node = null;

    @property({type:cc.Label,tooltip:"参数文本"})
    lbText:cc.Label = null;

    data:any = null;

    page:level_peopleArchery_openBoxDialog = null;

    bindData(data:any,page:level_peopleArchery_openBoxDialog){
        this.data = data;
        this.page = page;
        this.refrenshItem();
    }

    refrenshItem(){
        this.videoNode.active = this.data.videoFlag == "1";
        let str = O1HD.getManagers().peopleArcheryManager.getOptionText(this.data);
        this.lbText.string = str;
        this.loadIcon();
    }

    loadIcon(){
        //TODO 加载icon
    }

    onBtnMe(){
        if(this.data.videoFlag == "1"){
            if(O1HD.getServices().userSrv.getCoins() < 1){
                O1HD.getModules().uiControlModule.showMessageBox("免广告币不足");
                return;
            }
            O1HD.getServices().userSrv.setCoins(-1,true);
        }
        // this.page.selectItem(this);
    }

}
